The Grumpy Programmer's PHPUnit Cookbook by Chris Hartjes
Author:Chris Hartjes
Language: eng
Format: epub, mobi, pdf
Publisher: leanpub.com
Published: 2014-01-20T16:00:00+00:00
More Object Testing Tricks
Testing Traits
Because Traits can be defined once, but used many times, you will not want to necessarily test the functionality defined in traits in every object in which they are consumed. At the same time, you do want to test the traits themselves.
PHPUnit 3.6 and newer offers functionality for mocking traits via the getObjectForTrait() method; this will return an object composing the trait, so that you can unit test only the trait itself.
Here’s a sample trait:
1 <?php 2 trait Registry 3 { 4 protected $values = array(); 5 6 public function set($key, $value) 7 { 8 $this->values[$key] = $value; 9 } 10 11 public function get($key) 12 { 13 if (!isset($this->values[$key])) { 14 return false; 15 } 16 17 return $this->values[$key]; 18 } 19 }
Download
The Grumpy Programmer's PHPUnit Cookbook by Chris Hartjes.mobi
The Grumpy Programmer's PHPUnit Cookbook by Chris Hartjes.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
ActiveX | ASP.NET |
Cold Fusion | CSS |
DHTML | Java Server Pages |
JavaScript | PHP |
Python | Ruby |
XSL |
Hello! Python by Anthony Briggs(9867)
The Mikado Method by Ola Ellnestam Daniel Brolund(9747)
Dependency Injection in .NET by Mark Seemann(9293)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7745)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7517)
Svelte with Test-Driven Development by Daniel Irvine(6846)
Test-Driven Development with PHP 8 by Rainier Sarabia(6564)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6512)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(6431)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6378)
Web Development with Django by Ben Shaw Saurabh Badhwar(5882)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5783)
React Application Architecture for Production by Alan Alickovic(5624)
Kotlin in Action by Dmitry Jemerov(5019)
Audition by Ryu Murakami(4555)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4297)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4284)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4134)
Functional Programming in JavaScript by Mantyla Dan(4018)
